<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform @deleteItem="deleteUserItem" ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {buildSubFormData, subOnLoad, changeEditor,configSelectData,hasValue} from '@/static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr,errorModal} from '@/static/js/common.js';
	import urlUtil from '@/static/js/urlUtil.js'
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				newProductIdCacheKey: 'qam-cgjy-incomingInspectionReport-title3-newProductIdCacheKey',
				unitCache: 'qam-cgjy-incomingInspectionReport-title3-unitCacheKey',
				otherNewProductDatas: [],
				bomShowCache:'qam-cgjy-incomingInspectionReport-title3-bomShow-CacheKey',
				unqualifiedNumber: '',
				qualifiedInspectionNumber: '',
				actualSample: '',
				rejectionNumber: '',
			})
		},
		methods:{
			verifyBomShowId(){
				let _that = this
				let formdata= _that.$refs.autoform.formdata
				if(!_that.$refs.autoform.formdata.newProductId){
					let title = _that.$refs.autoform.getEditorTitle("title3","newProductId")
					_that.om.toast('请先选择'+title)
					return false
				}else{
					_that.$refs.autoform.changeEditor("title3","bomShowId",{
						link:'../../public/pageSearch/pageSearch',
						"linkParam":{
							other:JSON.stringify({
								productShowId:_that.$refs.autoform.formdata.newProductId,
								firstId:''
							}),
							url:'bomShow/getBomShowByProductShowPage',
							initload:true,
							cachename:_that.bomShowCache,
							namefield:'identificationCode',
							notefield:'effectiveDate'
						}
					})
					return true
				}
			},
			onInputAcceptanceNumber(num){
				let _that = this;
				// _that.$refs.autoform.formdata.rejectionNumber = Number(num) + 1;
				if(_that.$refs.autoform.formdata.rejectionNumber){
					let znum = Number(_that.$refs.autoform.formdata.rejectionNumber) || 0;
					if(Number(num) > znum || Number(num) == znum){
						let title1 = _that.$refs.autoform.getEditorTitle("title3","acceptanceNumber")
						let title2 = _that.$refs.autoform.getEditorTitle("title3","rejectionNumber")
						errorModal(_that,'提示信息',title1 + '不能大于等于'+ title2,()=>{
							_that.$refs.autoform.clear('title3', 'acceptanceNumber')
						})
					}
				}
				
				if(_that.$refs.autoform.formdata.unqualifiedNumber < num || _that.$refs.autoform.formdata.unqualifiedNumber == num){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6227
					_that.$refs.autoform.formdata.batchInspectionConclusion = '合格'
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}else if(_that.$refs.autoform.formdata.unqualifiedNumber > _that.$refs.autoform.formdata.rejectionNumber || _that.$refs.autoform.formdata.unqualifiedNumber == _that.$refs.autoform.formdata.rejectionNumber){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6226
					_that.$refs.autoform.formdata.batchInspectionConclusion = '不合格'
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","textarea")
				}else{
					_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId')
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}
			},
			onInputRejectionNumber(num){
				let _that = this;
				let znum = Number(_that.$refs.autoform.formdata.acceptanceNumber) || 0;
				if(Number(num) < znum || Number(num) == znum){
					let title1 = _that.$refs.autoform.getEditorTitle("title3","acceptanceNumber")
					let title2 = _that.$refs.autoform.getEditorTitle("title3","rejectionNumber")
					errorModal(_that,'提示信息',title2 + '不能小于等于'+ title1,()=>{
						_that.$refs.autoform.clear('title3', 'rejectionNumber');
					})
				}
				
				if(_that.$refs.autoform.formdata.unqualifiedNumber < _that.$refs.autoform.formdata.acceptanceNumber || _that.$refs.autoform.formdata.unqualifiedNumber == _that.$refs.autoform.formdata.acceptanceNumber){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6227
					_that.$refs.autoform.formdata.batchInspectionConclusion = '合格'
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}else if(_that.$refs.autoform.formdata.unqualifiedNumber > num || _that.$refs.autoform.formdata.unqualifiedNumber == num){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6226
					_that.$refs.autoform.formdata.batchInspectionConclusion = '不合格'
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","textarea")
				}else{
					_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId')
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}
			},
			onInputQualifiedInspection(val){
				let _that = this
				if(_that.unqualifiedNumber == -1){
					errorModal(_that,'提示信息','抽样方案 第1行的样本不合格数需优先完成编辑！',()=>{
						_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber');
					})
				}
				if(_that.$refs.autoform.formdata.actualArrivalQuantity){
					if(Number(val)>_that.$refs.autoform.formdata.actualArrivalQuantity){
						errorModal(_that,'提示信息','许可入库数量不能大于到货数量！',()=>{
							_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber');
						})
					}
				}
			},
			clearDisposalOfNonconformities(){
				let _that = this
				_that.$refs.autoform.clear("title2","disposalOfNonconformities")
				_that.$refs.autoform.clear("title2","qualifiedInspectionNumber")
			},
			onSelectDisposalOfNonconformities(item){
				let _that = this
				let formdata = _that.$refs.autoform.formdata
				if(formdata.batchInspectionConclusionId == '6226'){
					if(item.code == '40771'){
						if(formdata.damageNumber){
							formdata.qualifiedInspectionNumber = Number(formdata.actualArrivalQuantity) - Number(formdata.damageNumber)
						}else{
							formdata.qualifiedInspectionNumber = Number(formdata.actualArrivalQuantity)
						}
					}
				}
			},
			initLoad(){
				let _that = this
				let pro1 = _that.om.request('dictSource/loadCombo', { sourceId: 283,categoryId: 6431 });
				let pro2 = _that.om.request('dictSource/loadCombo', { sourceId: 283,categoryId: 6175 });
				let pro3 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 7488 });
				let pro4 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 8333 });
				let pro5 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 8338 });
				let pro6 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 7492 });
				let pro7 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 7489 });
				let pro8 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 7521 });
				let pro9 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 8955 });
				let pro10 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 7505 });
				let pro11 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 9009 });
				let pro12 = _that.om.request('dictSource/loadCombo', { sourceId: 289,categoryId: 9004 });
				Promise.all([pro1,pro2,pro3,pro4,pro5,pro6,pro7,pro8,pro9,pro10,pro11,pro12]).then(res=>{
					_that.$refs.autoform.changeEditor("title3", "whetherExemptionInspectionId", "data", configSelectData(res[0],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "whetherExemptionInspectionId")
					_that.$refs.autoform.changeEditor("title3", "batchInspectionConclusionId", "data", configSelectData(res[1],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "batchInspectionConclusionId")
					// _that.$refs.autoform.changeEditor("title3", "inspectionSchemeId", "data", configSelectData(res[2],"id","text"))
					// _that.$refs.autoform.initSelectIndex("title3", "inspectionSchemeId")
					// _that.$refs.autoform.changeEditor("title3", "inspectionMethodId", "data", configSelectData(res[3],"id","text"))
					// _that.$refs.autoform.initSelectIndex("title3", "inspectionMethodId")
					// _that.$refs.autoform.changeEditor("title3", "testRulesId", "data", configSelectData(res[4],"id","text"))
					// _that.$refs.autoform.initSelectIndex("title3", "testRulesId")
					// _that.$refs.autoform.changeEditor("title3", "inspectionLevelId", "data", configSelectData(res[5],"id","text"))
					// _that.$refs.autoform.initSelectIndex("title3", "inspectionLevelId")
					_that.$refs.autoform.changeEditor("title3", "inspectionStandardTypeId", "data", configSelectData(res[6],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "inspectionStandardTypeId")
					_that.$refs.autoform.changeEditor("title3", "samplingStandardId", "data", configSelectData(res[7],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "samplingStandardId")
					_that.$refs.autoform.changeEditor("title3", "disposalOfNonconformitiesId", "data", configSelectData(res[8],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "disposalOfNonconformitiesId")
					_that.$refs.autoform.changeEditor("title3", "batchUnqualifiedId", "data", configSelectData(res[9],"id","text"))
					_that.$refs.autoform.initSelectIndex("title3", "batchUnqualifiedId")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","data",configSelectData(res[10],'id','text'))
					_that.$refs.autoform.initSelectIndex("title3","unqualifiedPhenomenonCategoryId")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","data",configSelectData(res[11],'id','text'))
					_that.$refs.autoform.initSelectIndex("title3","unqualifiedFindLocationId")
					_that.$nextTick(function(){
						if(_that.qualifiedInspectionNumber == -1){
							_that.$refs.autoform.clear("title3","qualifiedInspectionNumber")
						}
						if(_that.unqualifiedNumber != -1 && _that.rejectionNumber != -1){
							if(Number(_that.unqualifiedNumber)<Number(_that.rejectionNumber)){
								_that.$refs.autoform.formdata.batchInspectionConclusionId = 6227
								_that.$refs.autoform.formdata.batchInspectionConclusion = '合格'
							}else{
								_that.$refs.autoform.formdata.batchInspectionConclusionId = 6226
								_that.$refs.autoform.formdata.batchInspectionConclusion = '不合格'
							}
						}
						if(_that.unqualifiedNumber != -1 && _that.actualSample != -1){
							_that.$refs.autoform.formdata.defectRatio = (Number(_that.unqualifiedNumber) * 100 / Number(_that.actualSample)).toFixed(2)
						}
						
						if(_that.$refs.autoform.formdata.batchInspectionConclusionId == 6226){
							// _that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","selectbox")
							_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","selectbox")
							_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","selectbox")
							_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","selectbox")
							_that.$refs.autoform.changeEditor("title3","defectDescription","type","textarea")
						}else{
							// _that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","labelbox")
							_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
							_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
							_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
							_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
						}
					})
				})
			},
			clearNewProductId(){
				let _that = this
				_that.$refs.autoform.clear('title3', 'newProductId');
				_that.$refs.autoform.clear('title3', 'productCode');
				_that.$refs.autoform.clear('title3', 'newProductName');
				_that.$refs.autoform.clear('title3', 'newProductStd');
				_that.$refs.autoform.clear('title3', 'unitId');
				_that.$refs.autoform.clear('title3', 'englishName');
				_that.$refs.autoform.clear('title3', 'commonName');
				_that.$refs.autoform.clear('title3', 'whetherExemptionInspectionId');
				_that.$refs.autoform.clear('title3', 'actualArrivalQuantity');
				_that.$refs.autoform.clear('title3', 'actualArrivalDate');
				_that.$refs.autoform.clear('title3', 'damageNumber');
				_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId');
				_that.$refs.autoform.clear('title3', 'inspectionRecordCode');
				_that.$refs.autoform.clear('title3', 'defectDescription');
				_that.$refs.autoform.clear('title3', 'remark');
				_that.$refs.autoform.clear('title3', 'keyFlagId');
				_that.$refs.autoform.clear('title3', 'batchUnqualifiedId');
				_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId');
				_that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","labelbox")
				_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
				_that.$refs.autoform.clear('title3', 'productUnqualifiedQuality');
				_that.$refs.autoform.clear('title3', 'testRulesId');
				_that.$refs.autoform.clear('title3', 'inspectionLevelId');
				_that.$refs.autoform.clear('title3', 'inspectionSchemeId');
				_that.$refs.autoform.clear('title3', 'inspectionMethodId');
				_that.$refs.autoform.clear('title3', 'valueAQLId');
			},
			onInputDamageNumber(num){
				let _that = this;	
				if(_that.$refs.autoform.formdata.actualArrivalQuantity){
					if(Number(num) >  Number(_that.$refs.autoform.formdata.actualArrivalQuantity)){
						errorModal(_that,'提示信息','样本破坏数不能大于到货数量',()=>{
							_that.$refs.autoform.clear('title3', 'damageNumber');
						})
					}
				}
			},
			onInputQualifiedDamageNumber(num){
				let _that = this;
				let znum = Number(_that.$refs.autoform.formdata.quantity) || 0;
				let num2 = Number(_that.$refs.autoform.formdata.damageNumber) || 0;
				if(znum>0 && Number(num) + num2 > znum){
					errorModal(_that,'提示信息','样本破坏数加合格品破坏数不能大于数量'+znum,()=>{
						_that.$refs.autoform.clear('title3', 'qualifiedDamageNumbe');
					})
				}
			},
			onSelectBatchInspectionConclusion(item){
				let _that = this
				let formdata = 	_that.$refs.autoform.formdata
				formdata.batchInspectionConclusionId = item.id
				formdata.batchInspectionConclusion = item.text
				if(item.code == "38205"){
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber');
					_that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","selectbox")
				}
				if(item.code == "38206"){
					if(formdata.damageNumber){
						formdata.qualifiedInspectionNumber = Number(formdata.actualArrivalQuantity) - Number(formdata.damageNumber)
					}else{
						formdata.qualifiedInspectionNumber = Number(formdata.actualArrivalQuantity)
					}
					_that.$refs.autoform.clear('title3', 'batchUnqualifiedId');
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId');
					_that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
				}
			},
			clearBatchInspectionConclusion(){
				let _that = this
				_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId');
				_that.$refs.autoform.clear('title3', 'batchUnqualifiedId');
				_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId');
				_that.$refs.autoform.changeEditor("title3","batchUnqualifiedId","type","labelbox")
				_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
			},
			changeActualSample(num){
				let _that = this;
				let znum = Number(_that.$refs.autoform.formdata.actualArrivalQuantity) || 0;
				let znum2 = Number(_that.$refs.autoform.formdata.unqualifiedNumber) || 0;
				if(_that.$refs.autoform.formdata.actualArrivalQuantity){
					if(Number(num) > znum){
						errorModal(_that,'提示信息','抽样数量不能大于到货数量'+znum,()=>{
							_that.$refs.autoform.clear('title3', 'actualSample');
						})
					}else{
						_that.$refs.autoform.formdata.defectRatio = (parseFloat((znum2/Number(num)).toFixed(2))*100).toFixed(0) || 0
						if(_that.$refs.autoform.formdata.defectRatio == 'NaN'){
							_that.$refs.autoform.formdata.defectRatio = ''
						}
					}
				}
				
				if(_that.$refs.autoform.formdata.damageNumber > Number(num)){
					errorModal(_that,'提示信息','抽样数量不能小于样本破坏数',()=>{
						_that.$refs.autoform.clear('title3', 'actualSample');
					})
				}
				
				if(znum2 > Number(num)){
					errorModal(_that,'提示信息','抽样数量不能小于样本不合格数',()=>{
						_that.$refs.autoform.clear('title3', 'actualSample');
					})
				}
			},
			changeUnqualifiedNumber(num){
				let _that = this;
				let znum = Number(_that.$refs.autoform.formdata.actualSample) || 0;
				if(_that.$refs.autoform.formdata.actualSample){
					if(Number(num) > znum){
						errorModal(_that,'提示信息','样本不合格数不能大于抽样数量'+znum,()=>{
							_that.$refs.autoform.clear('title3', 'unqualifiedNumber');
						})
					}else{
						_that.$refs.autoform.formdata.defectRatio = (parseFloat((Number(num)/znum).toFixed(2))*100).toFixed(0) || 0
						if(_that.$refs.autoform.formdata.defectRatio == 'NaN'){
							_that.$refs.autoform.formdata.defectRatio = ''
						}
					}
				}
				
				if(num < _that.$refs.autoform.formdata.acceptanceNumber || num == _that.$refs.autoform.formdata.acceptanceNumber){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6227
					_that.$refs.autoform.formdata.batchInspectionConclusion = '合格'
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}else if(num > _that.$refs.autoform.formdata.rejectionNumber || num == _that.$refs.autoform.formdata.rejectionNumber){
					_that.$refs.autoform.formdata.batchInspectionConclusionId = 6226
					_that.$refs.autoform.formdata.batchInspectionConclusion = '不合格'
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","selectbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","textarea")
				}else{
					_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId')
					_that.$refs.autoform.clear('title3', 'qualifiedInspectionNumber')
					_that.$refs.autoform.clear('title3', 'disposalOfNonconformitiesId')
					_that.$refs.autoform.changeEditor("title3","disposalOfNonconformitiesId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedPhenomenonCategoryId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","unqualifiedFindLocationId","type","labelbox")
					_that.$refs.autoform.changeEditor("title3","defectDescription","type","labelbox")
				}
			},
			changeActualArrivalQuantity(num){
				let _that = this;
				let znum = Number(_that.$refs.autoform.formdata.actualSample) || 0;
				if(Number(num) < znum){
					errorModal(_that,'提示信息','到货数量不能小于抽样数量'+znum,()=>{
						_that.$refs.autoform.clear('title3', 'actualArrivalQuantity');
					})
				}
			},
			clearUnqualifiedNumber(){
				let _that = this;
				_that.$refs.autoform.clear('title3', 'unqualifiedNumber');
				_that.$refs.autoform.clear('title3', 'defectRatio');
				_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId');
			},
			clearActualSample(){
				let _that = this;
				_that.$refs.autoform.clear('title3', 'actualSample');
				_that.$refs.autoform.clear('title3', 'defectRatio');
			},
			clearAcceptanceNumber(){
				let _that = this;
				_that.$refs.autoform.clear('title3', 'acceptanceNumber');
				_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId');
			},
			clearRejectionNumber(){
				let _that = this;
				_that.$refs.autoform.clear('title3', 'rejectionNumber');
				_that.$refs.autoform.clear('title3', 'batchInspectionConclusionId');
			},
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key:_that.newProductIdCacheKey,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							let num = 0;
							for(let i=0; i<_that.otherNewProductDatas.length;i++){
								if(_that.otherNewProductDatas[i].newProductId == d.id){
									num = 1
								}
							}
							
							if(num == 1){
								errorModal(_that,'提示信息','物料编码:'+d.newProductCode+'已存在，请重新选择！',()=>{
									_that.clearNewProductId()
								})
							}else{
								formdata.newProductId = d.id
								formdata.newProductCode = d.newProductCode
								formdata.productCode = d.productCode
								formdata.newProductName = d.newProductName
								formdata.newProductStd = d.newProductStd
								formdata.unitId = d.unitId
								formdata.unitName = d.unitName
								formdata.englishName = d.englishName
								formdata.commonName = d.commonName
								formdata.keyFlagId = d.keyFlag
								formdata.keyFlagStr = d.keyFlagStr
								
								_that.om.request(
									'incomingInspectionReport/getProductUnqualifiedQuality',
									{
										supplierId: '',
										newProductId: d.id
									},'post').then(zres=>{
										formdata.productUnqualifiedQuality = zres.value
								})
								
								_that.om.request(
									'bomShow/getAccordingProductHaveBom',
									{
										productShowId: d.id
									}).then(zres=>{
										formdata.newProductCode = zres.value.newProductCode
								})
								
								_that.om.request(
									'productShowSecond/getProductQualityControl',
									{
										productId: d.id
									},'post').then(zres=>{
										formdata.testRulesId = zres.value.samplingRuleId
										formdata.testRulesName = zres.value.samplingRuleName
										formdata.inspectionLevelId = zres.value.inspectionLevelId
										formdata.inspectionLevelName = zres.value.inspectionLevelName
										formdata.inspectionSchemeId = zres.value.inspectionPlanId
										formdata.inspectionSchemeName = zres.value.inspectionPlanName
										formdata.inspectionMethodId = zres.value.samplingSchemeId
										formdata.inspectionMethodName = zres.value.samplingSchemeName
										formdata.valueAQLId = zres.value.valueAQLId
										formdata.valueAQLName = zres.value.valueAQLName
								})						
							}
							
							uni.removeStorage({
								key:_that.newProductIdCacheKey
							})
						}
					}
				})
				uni.getStorage({
					key:_that.unitCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.unitId = d.unitId
							formdata.unitName = d.unitName
							uni.removeStorage({
								key:_that.unitCache
							})
						}
					}
				})
				uni.getStorage({
					key:_that.bomShowCache,
					success:(res)=>{
						if(res.data){
							let d = res.data
							let formdata = _that.$refs.autoform.formdata
							formdata.bomShowId = d.bomShowId
							formdata.bomShowVersionNumber = d.identificationCode
							formdata.productSignCode = d.productSignCode
							uni.removeStorage({
								key:_that.bomShowCache
							})
						}
					}
				})
				
			}
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				// if(e.unqualifiedNumber){
				// 	_that.unqualifiedNumber = e.unqualifiedNumber
				// }
				// if(e.qualifiedInspectionNumber){
				// 	_that.qualifiedInspectionNumber = e.qualifiedInspectionNumber
				// }
				
				_that.unqualifiedNumber = uni.getStorageSync('unqualifiedNumberKey')
				_that.qualifiedInspectionNumber = uni.getStorageSync('qualifiedInspectionNumberKey')
				_that.actualSample = uni.getStorageSync('actualSampleKey')
				_that.rejectionNumber = uni.getStorageSync('rejectionNumberKey')
			if(e.configDataCacheKey){
				uni.getStorage({
					key: e.configDataCacheKey,
					success: function(res) {
						if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
							_that.autoformdata = res.data
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							
							changeEditor('title3', "newProductId", {
								'link': '../../public/pageSearch/pageSearch',
								"linkParam": {
									url:'productShowSecond/getProductPage',
									namefield: 'newProductCode',
									extrafield:'newProductStd',
									notefield:'newProductName',
									searchfield: "q",
									initload:true,
									cachename: _that.newProductIdCacheKey,
								}
							}, null, _that.autoformdata)
							
							changeEditor("title3","unitId",{
								link:'../../public/pageSearch/pageSearch',
								"linkParam":{
									other:JSON.stringify({}),		
									url:'uomGroup/selectAllChildGrid',
									initload:true,
									searchfield:'q',
									namefield:'unitName',
									extrafield:'unitCode',
									notefield:'unitGroupName',
									cachename:_that.unitCache
								}
							},null,_that.autoformdata)
							
							changeEditor(_that.autoformdata[0].editors, "fileList", "fileSaveNameField", "fileSaveName")
							changeEditor(_that.autoformdata[0].editors, "fileList", "uploadUrl", "uploadFileData/uploadInterimFile")
							changeEditor(_that.autoformdata[0].editors, "fileList", "loadUrl", "uploadFileData/getInterimFile")
							changeEditor(_that.autoformdata[0].editors, "fileList", "fileUploadKey", 142)
							if(_that.formdata.fileList) {
								var tempFileList = []
								var fileUrlList = _that.formdata.fileList.map(t=>{
									tempFileList.push(t.fileSaveName)
									return t.fileSaveName
								})
								changeEditor(_that.autoformdata[0].editors, "fileList", "fileUrlList", fileUrlList)
								changeEditor(_that.autoformdata[0].editors, "fileList", "tempFileList", tempFileList)
							}
							
							_that.otherNewProductDatas = _that.datas.filter(e => e.newProductId)

							_that.initLoad()
							
							}
						}
					})
				}
			})
		}
	}
</script>

<style>
</style>                                                                                                                                                                                                                                                                                                                                                                                                                                                         
